package com.mf.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 订单编号生成工具类
 *
 * @author: Jiang Runqing
 * @date: 2018-09-28 21:26
 */
public class OrderSNUtil {

    public String createOrderSN() {
        String str = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        str = sdf.format(new Date());


        String sources = "0123456789";
        Random rand = new Random();
        StringBuffer flag = new StringBuffer();
        for (int j = 0; j < 6; j++) {
            flag.append(sources.charAt(rand.nextInt(9)) + "");
        }
        str += flag.toString();

        return str;
    }

    public static void main(String[] args) {

        System.out.println(new OrderSNUtil().createOrderSN());

    }
}
